package com.kuangstudy.collection.set;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * ClassName: UnsafeBuyTicket
 * date: 2021/07/12 19:46:48
 * set特点
 * 无序、没有下标、不能重复
 *
 * @author zlk
 */
public class Demo1 {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();
        set.add("kk4");
        set.add("kk1");
        set.add("kk3");
        set.add("kk2");
        set.add("kk1");

        System.out.println(set.toString());
        set.remove("kk1");
        System.out.println(set.toString());
        for (String s : set) {
            System.out.println(s);
        }
        System.out.println("================");
        /*使用迭代器遍历*/
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }


    }
}
